/*
 * 用户管理模块
 */

import { LoginFormType } from '@/interfaces/PagesType/LoginType'
export interface ResultType {
  user_id: number
  username: string
  token: string
}

// 登录
export function Login() {
  return {
    url: 'user/login',
    type: 'post',
    response: (config: LoginFormType): Result<ResultType> => {
      const { username } = config
      if (username === 'admin') {
        return {
          code: 200,
          result: {
            user_id: 1,
            username: '不求甚解',
            token: 'token'
          },
          message: '登录成功'
        }
      }
      return {
        code: 400,
        message: '用户名错误',
        result: null
      }
    }
  }
}
